/*
** parse_cmd.c for my_irc in /home/billey_b/projet/my_irc/my-irc-a
** 
** Made by Bastien Billey
** Login   <billey_b@epitech.net>
** 
** Started on  Tue Apr 17 13:08:09 2012 Bastien Billey
** Last update Tue Apr 17 13:08:10 2012 Bastien Billey
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "client.h"

char *parse_cmd(char *cmd)
{
  int	i;
  int	j;
  char	*final;

  i = 0;
  j = 0;
  final = xmalloc(sizeof(char *) + strlen(cmd));
  while (cmd[i] == ' ' && cmd[i])
    i++;
  while (cmd[i] != ' ' && cmd[i])
    final[j++] = cmd[i++];
  return final;
}

void	parse_addr_and_port(t_client *client)
{
  int	i;
  int	j;

  i = 0;
  j = 0;
  client->cmd.arg1 = xmalloc(sizeof(client->cmd.buff));
  client->cmd.arg2 = xmalloc(sizeof(client->cmd.buff));
  while (client->cmd.buff[i] == ' ' && client->cmd.buff[i])
    i++;
  while (client->cmd.buff[i] != ' ' && client->cmd.buff[i])
    i++;
  while (client->cmd.buff[i] == ' ' && client->cmd.buff[i])
    i++;
  while (client->cmd.buff[i] != ' ' && client->cmd.buff[i])
    client->cmd.arg1[j++] = client->cmd.buff[i++];
  while (client->cmd.buff[i] == ' ' && client->cmd.buff[i])
    i++;
  j = 0;
  while (client->cmd.buff[i] != ' ' && client->cmd.buff[i])
    client->cmd.arg2[j++] = client->cmd.buff[i++];
}
